home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Arrays / ArrayOf.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  1.9 KB  |  53 lines  |  [TEXT/CWIE]

  1. // ArrayOf.h
  2.  
  3. #ifndef ArrayOf_h
  4. #define ArrayOf_h
  5.  
  6. #ifndef ConstArrayOf_h
  7. #include "ConstArrayOf.h"
  8. #endif
  9.  
  10. template < class Element >
  11. class ArrayOf: public ConstArrayOf< Element >
  12.   {
  13.     typedef ArrayOf< Element > ArrayType;
  14.     typedef ConstArrayOf< Element > ConstArrayType;
  15.  
  16.     private:
  17.         ArrayOf( ConstArrayType theArrayOf )
  18.           : ConstArrayOf< Element >( theArrayOf )
  19.           {}
  20.         
  21.     public:
  22.         ArrayOf()        {}        
  23.         ArrayOf( Element *theStart, uint32 theLength )
  24.           : ConstArrayOf< Element >( theStart, theLength )
  25.           {}
  26.  
  27.         Element *Start() const                    { return const_cast<Element *>( ConstArrayType::Start() ); }
  28.         Element *End() const                        { return const_cast<Element *>( ConstArrayType::End() ); }
  29.         
  30.         Element& operator[]( uint32 i ) const
  31.             { return const_cast<Element &>( ConstArrayType::operator[]( i ) ); }
  32.         
  33.         ArrayType Head( uint32 position ) const                { return ConstArrayType::Head( position ); }
  34.         ArrayType Tail( uint32 position ) const                { return ConstArrayType::Tail( position ); }
  35.         ArrayType Middle( URange32 range ) const                { return ConstArrayType::Middle( range ); }
  36.  
  37.         void Append( ArrayType tail )                                { ConstArrayType::Append( tail ); }
  38.         void Prepend( ArrayType head )                            { ConstArrayType::Prepend( head ); }
  39.         
  40.         void operator+=( ArrayType tail )                        { ConstArrayType::Append( tail ); }
  41.         ArrayType operator+( ArrayType tail )                    { return ConstArrayType::operator+( tail ); }
  42.  
  43.         ArrayType operator&( ConstArrayType r ) const        { return ConstArrayType::operator&( r ); }
  44.         void operator|=( ArrayType r )                            { ConstArrayType::operator|=( r ); }
  45.         ArrayType operator|( ArrayType r ) const                { return ConstArrayType::operator|( r ); }
  46.         ConstArrayType operator|( ConstArrayType r ) const    { return ConstArrayType::operator|( r ); }
  47.         
  48.         uint32 operator<<( ConstArrayType r ) const;        // returns the amount copied
  49.         uint32 BitwiseCopy( ConstArrayType r ) const;
  50.   };
  51.  
  52. #endif
  53.